package org.xin.security.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import org.xin.common.result.Result;
import org.xin.security.pojo.entity.SysMenu;
import org.xin.security.service.ISysMenuService;

import org.xin.framework.base.controller.IBaseController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
* <p>
    * 系统模块-菜单权限表 前端控制器
    * </p>
*
* @author: xin
* @date: Create in 2021-09-29
*/
@Api(tags = "系统模块-菜单")
@CrossOrigin
@RestController
@RequestMapping("/sysMenu")
public class SysMenuController extends IBaseController<SysMenu, ISysMenuService> {

    @ApiOperation("获取当前用户可用菜单列表")
    @GetMapping("/getMenus")
    public Result getUserInfo(HttpServletRequest request, HttpServletResponse response){
        List<SysMenu> sysMenus = service.selectMenusByLoginUser(request);
        return Result.success(service.buildMenuTreeSelect(sysMenus));
    }
}

